<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
  <head>
    <title>Title</title>
    <script src="/static/jquery-2.1.4.js" type="text/javascript" charset="utf-8"></script>
  </head>
  <body>
      <form action="/student?method=add" method="post">
        <table border="1" cellspacing="0">
          <tr>
            <td>用户名：</td>
            <td><input type="text" name="name"></td>
          </tr>
          <tr>
            <td>年龄：</td>
            <td><input type="text" name="age"></td>
          </tr>
          <tr>
            <td>性别：</td>
            <td><input type="text" name="gender"></td>
          </tr>
          <tr>
            <td>班级：</td>
            <td>
              <select id="banjiId" name="banjiId">
                <option>请选择班级</option>
              </select>
            </td>
          </tr>
          <tr>
            <td><input type="submit" value="添加"></td>
            <td><input type="reset" value="重置"></td>
          </tr>
        </table>
      </form>
  </body>
  <script>
    $(function () {
        $.post(
            '/banji?method=selectAll',
             function (jsonObj) {
               console.log(jsonObj);
               $(jsonObj).each(function () {
                 //$('#banjiId').append('<option value="1">Java</option>');
                 $('#banjiId').append('<option value="'+this.id+'">'+this.name+'</option>');
               })
             },
             'json'
        );
    })
  </script>
</html>
